#include "osgb/OsgbModel.h"

void to_json(json & j, const Asset & p) {
	j = json{
		{"version", p.version},
		{"gltfUpAxis",p.gltfUpAxis } 
	};
}

void from_json(const json & j, Asset & p) {
	j.at("version").get_to(p.version);
	j.at("gltfUpAxis").get_to(p.gltfUpAxis);
}

void to_json(json & j, const BoundingVolume & p) {
	j = json{
		{"box", p.box}
	};
}

void from_json(const json & j, BoundingVolume & p) {
	j.at("box").get_to(p.box);
}


void to_json(json & j, const Content & p) {
	j = json{
		{"uri", p.uri}
	};
}

void from_json(const json & j, Content & p) {
	j.at("uri").get_to(p.uri);
}

 void to_json(json & j, const Tile & p) {
	 j = json{ 
		 {"geometricError", p.geometricError},
		 {"boundingVolume",p.boundingVolume },
		 {"content",p.content  } ,
			{"children",p.children}
	 };
}

  void from_json(const json & j, Tile & p) {
	 j.at("geometricError").get_to(p.geometricError);
	 j.at("boundingVolume").get_to(p.boundingVolume);
	 j.at("content").get_to(p.content);
	 j.at("children").get_to(p.children);
 }


  void to_json(json& j, const Root& p)
  {
	  j = json{
	  {"boundingVolume" ,p.boundingVolume },
		{ "children",p.children} ,
	  { "transform", p.transform },
	  { "geometricError", p.geometricError } };
  }

  void from_json(const json& j, Root& p)
  {
	  j.at("geometricError").get_to(p.geometricError);
	  j.at("boundingVolume").get_to(p.boundingVolume);
	  j.at("transform").get_to(p.transform);
	  j.at("children").get_to(p.children);
  }


  void to_json(json& j, const TileSet& p) {
	  j = json{ {"geometricError", p.geometricError},
	  {"asset", p.asset },
	  {"root",p.root } };
  }

  void from_json(const json& j, TileSet& p)
  {
	  j.at("geometricError").get_to(p.geometricError);
	  j.at("asset").get_to(p.asset);
	  j.at("root").get_to(p.root);

  }